<!DOCTYPE html>
<html xmlns="http://www.w3c.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:p="http://primefaces.org/ui" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough" xmlns:c="http://java.sun.com/jsp/jstl/core">

<ui:decorate id="msrpDecoration" template="/resources/template/template-crud.xhtml">

  <ui:param name="title" value="Equipamento" />

  <ui:param name="managedBean" value="#{equipamentoBean}" />

  <ui:define name="botaoTopCadastro">

  </ui:define>

  <ui:define name="botaoTopExclusao">

  </ui:define>

  <ui:define name="parametroConsulta">

  </ui:define>

  <ui:define name="tabelaDados">

    <p:column headerText="Imei" resizable="true">
      <h:outputText styleClass="fonte" value="#{beanEnt.imei}" />
    </p:column>
    <p:column headerText="Serial">
      <h:outputText styleClass="fonte" value="#{beanEnt.serial}" />
    </p:column>
    <p:column headerText="Status">
      <h:outputText styleClass="fonte" value="#{beanEnt.status.descricao}" />
    </p:column>
    <p:column headerText="Leiturista" resizable="true">
      <h:outputText styleClass="fonte" value="#{beanEnt.leiturista.nome}" />
    </p:column>
    <p:column headerText="Data inativação">
      <h:outputText styleClass="fonte" value="#{beanEnt.dataInativacao}">
        <f:convertDateTime pattern="dd/MM/yyyy" />
      </h:outputText>
    </p:column>

  </ui:define>

  <ui:define name="formCadastro">

    <script>
    jQuery(function($){
           jQuery("#frmDados\\:dataInativacao").mask("99/99/9999",{placeholder:"dd/mm/yyyy"});
           /*$("#campoTelefone").mask("(999) 999-9999");
           $("#campoSenha").mask("***-****");*/
    });
  </script>

    <h:panelGrid columns="2" columnClasses="colunas">

      <h:outputLabel styleClass="fonte" value="Imei" />
      <p:inputMask id="imei" value="#{equipamentoBean.entity.imei}" required="true" requiredMessage="Imei é requerido." 
       	mask="999999999999999" />

      <h:outputLabel styleClass="fonte" value="Serial" />
      <h:inputText value="#{equipamentoBean.entity.serial}" required="true" requiredMessage="Serial é requerido." />

      <h:outputLabel styleClass="fonte" value="Chip" />
      <h:inputText value="#{equipamentoBean.entity.chip}" />

      <h:outputLabel id="numero" styleClass="fonte" value="Numero" />
      <h:inputText value="#{equipamentoBean.entity.numero}" maxlength="15" onkeypress="mascaraPhone9(this)">
      	<f:converter converterId="telefoneConverter"/>
      </h:inputText>

      <h:outputLabel styleClass="fonte" value="Data inativação" rendered="#{equipamentoBean.state eq 'alterar'}" />
      <h:inputText id="dataInativacao" value="#{equipamentoBean.entity.dataInativacao}" rendered="#{equipamentoBean.state eq 'alterar'}"
        converterMessage="Data informada está inválida.">
        <f:convertDateTime pattern="dd/MM/yyyy" locale="pt_BR" timeZone="America/Fortaleza" />
      </h:inputText>

      <h:outputLabel styleClass="fonte" value="Leiturista" />
      <h:selectOneMenu value="#{equipamentoBean.entity.leiturista}" required="true" requiredMessage="Leiturista é requerido." converter="entityConverter">
        <f:selectItem itemLabel="Selecione uma opção" />
        <f:selectItems var="_leiturista" itemValue="#{_leiturista}" itemLabel="#{_leiturista.nome}" value="#{equipamentoBean.lstLeiturista}" />
        <f:attribute name="itens" value="#{equipamentoBean.lstLeiturista}" />
      </h:selectOneMenu>

      <h:outputLabel styleClass="fonte" value="Status" rendered="#{equipamentoBean.state eq 'alterar'}" />
      <h:selectOneMenu value="#{equipamentoBean.entity.status}" rendered="#{equipamentoBean.state eq 'alterar'}" required="true" requiredMessage="Status é requerido.">
        <f:selectItems var="_status" itemValue="#{_status}" itemLabel="#{_status.descricao}" value="#{equipamentoBean.lstEnumStatus}" />
      </h:selectOneMenu>

    </h:panelGrid>

  </ui:define>

  <ui:define name="formExclusao">
    <h:panelGrid columns="2" columnClasses="colunas">

      <h:outputLabel styleClass="fonte" value="Imei" />
      <h:inputText value="#{equipamentoBean.entity.imei}" disabled="true" />

      <h:outputLabel styleClass="fonte" value="Serial" />
      <h:inputText value="#{equipamentoBean.entity.serial}" disabled="true" />

      <h:outputLabel styleClass="fonte" value="Chip" />
      <h:inputText value="#{equipamentoBean.entity.chip}" disabled="true" />

    </h:panelGrid>
  </ui:define>

</ui:decorate>

</html>